package com.swjd.controller;

import com.swjd.pojo.User;
import com.swjd.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/addUser")
    public String addUser(User user){
    return  "addUser";
}
    @RequestMapping("/deleteUser")
    public String deleteUser(User user){
        return  "redirect:/showUser";
    }
    @RequestMapping("/showUser")
    public String showUser(Model model){
        List<User> userList = userService.getUserList();
        System.out.println(userList);
        model.addAttribute("userList",userList);
        return  "userList";
    }
}

